package com.boarsoft.boar.batch.entity;

import java.io.Serializable;

/**
 * 批量定义
 * 
 * @author Mac_J
 *
 */
public class BatchInfo implements Serializable {

	protected static final long serialVersionUID = -26631754680228100L;

	/** 遇异常后无动作，批量直接失败，消可能还在执行的其它动作 */
	public static final short FAILABLE_STOP = 0;
	/** 忽略异常，只记录事件，不做处理（不中断父流程） */
	public static final short FAILABLE_IGNORE = 1;
	/** 遇异常后 续跑一次 当前批量，已成功的任务不再执行，失败的则会再跑一次 */
	public static final short FAILABLE_RESUME = 2;
	/** 遇异常后 重跑一次（从头开始，跑成功的子任务也再跑一遍） 当前批量 */
	public static final short FAILABLE_REDO = 3;

	/** 状态停用 */
	public static final short STATUS_DISABLE = 0;
	/** 状态启用 */
	public static final short STATUS_ENABLE = 1;
	
	/** 0 表示不冻结 */
	public static final short FREEZE_NONE = 0;
	/** -1表示永久冻结（前次执行必须完成且成功） */
	public static final short FREEZE_BLOCK = -1;

	/** 批量ID */
	protected String id;
	/** 所属分组（业务群），对应服务的分组 */
	protected String catalog;
	/** 批量ID */
	protected String code;
	/** 批量名称 */
	protected String name;
	/** 失败处理，两位数字，个位为策略，十位及以上为尝试次数 */
	protected short failable;
	/** 批量的冻结时间（两次调起的间隔时间），单位：分钟<br> */
	protected int freeze = FREEZE_NONE;
	/** 超时时间，单位分钟 */
	protected int timeout;
	/** 用于指定初始参数 */
	protected String params;
	/** 批量实现类 */
	protected String impl;

	/** 定时计划CRON表达式 */
	private String cron;
	/** 定时计划开始时间 */
	private String startTime;
	/** 定时计划终止时间 */
	private String stopTime;
	/** 停用还是启用 */
	private short status = STATUS_DISABLE;
	/** QuartzJob类 */
	private String job;

	/** 尝试续跑的时间间隔，单位分钟 */
	protected int period;
	/** 批量描述 */
	protected String memo;

	public String toString() {
		return new StringBuilder(catalog).append("/").append(code).toString();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public short getFailable() {
		return failable;
	}

	public void setFailable(short failable) {
		this.failable = failable;
	}

	public int getFreeze() {
		return freeze;
	}

	public void setFreeze(int freeze) {
		this.freeze = freeze;
	}

	public int getTimeout() {
		return timeout;
	}

	public void setTimeout(int timeout) {
		this.timeout = timeout;
	}

	public String getCatalog() {
		return catalog;
	}

	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}

	public String getParams() {
		return params;
	}

	public void setParams(String params) {
		this.params = params;
	}

	public String getImpl() {
		return impl;
	}

	public void setImpl(String impl) {
		this.impl = impl;
	}

	public String getCron() {
		return cron;
	}

	public void setCron(String cron) {
		this.cron = cron;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getStopTime() {
		return stopTime;
	}

	public void setStopTime(String stopTime) {
		this.stopTime = stopTime;
	}

	public short getStatus() {
		return status;
	}

	public void setStatus(short status) {
		this.status = status;
	}

	public String getJob() {
		return job;
	}

	public void setJob(String job) {
		this.job = job;
	}

	public int getPeriod() {
		return period;
	}

	public void setPeriod(int period) {
		this.period = period;
	}
}
